namespace AlmKickstart.Data.Migrations
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    internal sealed class Configuration : DbMigrationsConfiguration<AlmKickstart.Data.AlmKickstartEntities>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
        }

        protected override void Seed(AlmKickstart.Data.AlmKickstartEntities context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //

			if(context.ProjectTypes.Count() == 0)
			{
				context.ProjectTypes.Add(new ProjectType("Project"));
				context.ProjectTypes.Add(new ProjectType("Feature"));
				context.ProjectTypes.Add(new ProjectType("Task"));
				context.SaveChanges();
			}

			if(context.ProjectStatuses.Count() == 0)
			{
				context.ProjectStatuses.Add(new Status("New", "A newly-created item waiting to be reviewed by the project manager."));
				context.ProjectStatuses.Add(new Status("Approved", "The item has been approved by the project manager."));
				context.ProjectStatuses.Add(new Status("In Progress", "The item is being worked on."));
				context.ProjectStatuses.Add(new Status("Done", "Work on the item is done."));
				context.ProjectStatuses.Add(new Status("Rejected", "The project manager rejected the item."));
				context.SaveChanges();
			}
        }
    }
}
